<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="initial-scale=1.0,maximum-scale=1.0,minimum-scale=1.0,user-scalable=0, width=device-width"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <link rel="stylesheet" type="text/css" href="../css/api.css"/> 
    <link rel="stylesheet" type="text/css" href="../css/aui.css" />
    <link rel="stylesheet" type="text/css" href="../css/aui-win.css" />
    <link rel="stylesheet" type="text/css" href="../css/alpenlicebe.css"/>   
</head> 
<body>
    <div id="wrap"> 
        <div id="main"> 
			<ul id='ul_imgList' class="aui-list-view aui-grid-view"> 
				<li class="aui-list-view-cell aui-img aui-col-xs-6" style="position: relative;text-align: center;margin: 0 auto">
			        <img style="height:100px" class="aui-img-object" src="../image/1.jpg"> 
			        <div style="text-align: center; padding-top: 5px; position: absolute;z-index: 999;top: 65px; left: 10px; bottom: 0; right: 0;">
					 	<button onclick="api.closeWin();" style="width:48%;" class="aui-btn aui-btn-primary">查看</button>
					 	<button onclick="goto_testingPhotoFun();" style="width:48%;" class="aui-btn aui-btn-danger">移除</button>
					</div>
			    </li>
				<li class="aui-list-view-cell aui-img aui-col-xs-6" style="">
			        <img style="height:100px" class="aui-img-object" src="../image/2.jpg"> 
			    </li>
			    <li class="aui-list-view-cell aui-img aui-col-xs-6" style="">
			        <img style="height:100px" class="aui-img-object" src="../image/1.jpg"> 
			    </li>
			    <li class="aui-list-view-cell aui-img aui-col-xs-6" style="">
			        <img style="height:100px" class="aui-img-object" src="../image/2.jpg"> 
			    </li> 
			</ul>
			<div style="text-align: center; padding-top: 5px;">
			 	<button onclick="api.closeWin();" style="width:48%;" class="aui-btn aui-btn-primary">取消</button>
			 	<button onclick="goto_testingPhotoFun();" style="width:48%;background-color:#cc4b28;border-color:#cc4b28;" class="aui-btn aui-btn-primary">拍照</button>
			</div> 
        </div>
    </div>
</body>
<script type="text/javascript" src="../script/api.js"></script> 
<script type="text/javascript" src="../script/alpenlicebe.js"></script>
<script type="text/javascript" src="../script/zepto.min.js"></script> 
<script> 
    var apiready = function(){   
        //goto_loadAppAboutFun();
    }   
    function goto_testingPhotoFun(){
		api.confirm({
    		title: "系统提示",
    		msg: "您想要从哪里选取图片 ?",
    		buttons:["拍照", "相册", "取消"]
        },function(ret,err){
            var sourceType = "album";  
            if(1 == ret.buttonIndex){  
                sourceType = "camera";
            }else if(2 == ret.buttonIndex){  
                sourceType = "album";
            }else{ 
                return;
            }

            api.getPicture({
                sourceType: sourceType,
                encodingType: 'jpg',
                mediaValue: 'pic',
                destinationType: 'url',/*url\base64*/
           		targetWidth: 400,
          		targetHeight: 600,
           		saveToPhotoAlbum:true
            }, function(ret_img, err_img){
                if (ret_img) {
                	if(''==ret_img.data){
                		api.alert({title:'系统提示',msg:'没有选择照片'}); 
                		return;
                	}
                	api.showProgress({
						style: 'default',
						animationType: 'fade',
						title: '',
						text: '',
						modal: true
					});
                	api.ajax({
					    url: 'http://jiyang.sddzinfo.com/index.php?m=api&c=index&a=userImg&userID=2&phoneAppID='+api.deviceId,
					    method: 'post',
					    cache: false,
					    timeout: 30,
					    dataType: 'json',
					    returnAll:false,
					    data:{
					        values: {name: 'alpenlicebe'},
					        files: {file:ret_img.data}
					    }
					},function(ret_up,err_up){
					    if (ret_up) {
					        if("0"==ret_up.HEADER.RESULT){
					        	api.toast({msg:'上传成功',duration:2000,location:'middle'}); 
					        	var html="<li class='aui-list-view-cell aui-img aui-col-xs-4'>"+
									        "<img class='aui-img-object' src='"+ret_up.BODY.userImg+"'>"+
									    "</li>";
					        	$("#ul_imgList").append(html);  
								api.hideProgress(); 
							}else{
								api.alert({title:'系统提示',msg:ret_up.HEADER.RESULT_MESSAGE}); 
								api.hideProgress();
							} 
					    }else {
					        api.alert({
					            msg:('错误码：'+err_up.code+'；错误信息：'+err_up.msg+'网络状态码：'+err_up.statusCode)
					        });
					        api.hideProgress();
					    }; 
					}); 
                }else{
                	api.alert({title:'系统提示',msg:err_img.msg}); 
                }
            }); 
        });
    }
</script>
</html>
